package com.yuanss.backenddemo.utils;

import com.yuanss.backenddemo.entity.po.SysUser;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.shiro.SecurityUtils;

/**
 * @author yuanss
 * @version 1.0
 * @description Shiro工具类
 * @date 2024/6/15 22:09:33
 */
public class ShiroUtils {
    public static Long getUserId()
    {
        SysUser user = (SysUser)SecurityUtils.getSubject().getPrincipal();
        if(ObjectUtils.isEmpty(user)){
            throw new RuntimeException("获取用户id失败");
        }
        return user.getUserId();
    }
}
